<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>欢乐豆记录</title>
    <script type="text/javascript" src="js/jquery-1.11.3.js"></script>
    <link href="css/happybeanlist.css" rel="stylesheet" type="text/css" />
  </head>
  <body>
    <div class="miandiv">
      <div class="title">
        <ul>
          <li>编号</li>
          <li>欢乐豆</li>
          <li>时间</li>
          <li>来源</li>
        </ul>
      </div>
      <div class="list">
        <ul>
          <li title="1">1</li>
          <li title="+1000">+1000</li>
          <li title="2012-2-12 19:45:23">2012-2-12 19:45:23</li>
          <li title="充值">充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
        <ul>
          <li>1</li>
          <li>+1000</li>
          <li>2012-2-12 19:45:23</li>
          <li>充值</li>
        </ul>
      </div>
    </div>
  </body>
  <script>
    /*
    $(function () {
      $(window.parent)[0].setiframeHight($("body").height());
    });
    */

    $(function () {
      $(".list").empty();
      //查询欢乐豆记录的接口
      queryHistoryList();
    });

    //查询欢乐豆流水列表
    function queryHistoryList() {
      //获取当前登录用户id
      var uid = localStorage.getItem("uid");

      $.ajax({
        type: "post",
        url: "http://localhost:8080/happybean/querylist",
        data: {
          uid: uid,
        },
        success: function (data) {
          if (data.length == 0) {
            var html =
              ' <ul style="display: flex; width: 100%; height: 80px"> <li style="width: 100%;height: 100%;font-size: 26px;text-align: center;  line-height: 80px;">暂无记录</li></ul>';
            $(".list").append(html);
          } else {
            //data -> 记录列表
            //for -> data -> <tr></tr> -> <tbody>
            for (var i = 0; i < data.length; i++) {
              //从data数组中取出第i条记录
              var item = data[i];

              var source = "";
              if (item.source == 0) {
                source = "充值";
              } else if (item.source == 1) {
                source = "对局";
              } else if (item.source == 2) {
                source = "系统赠送";
              }

              var html =
                "<ul>" +
                '<li title="' +
                item.id +
                '">' +
                item.id +
                "</li>" +
                '<li title="' +
                (item.type == 0 ? "+" : "-") +
                item.beanNumber +
                '">' +
                (item.type == 0 ? "+" : "-") +
                item.beanNumber +
                "</li>" +
                '<li title="' +
                item.createTime +
                '">' +
                item.createTime +
                "</li>" +
                '<li title="' +
                source +
                '">' +
                source +
                "</li>" +
                "</ul>";

              $(".list").append(html);
            }
          }
          $(window.parent)[0].setiframeHight($("body").height());
        },
      });
    }
  </script>
</html>
